package com.zscat.mallplus.center.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zscat.mallplus.center.BaseController;
import com.zscat.mallplus.center.entity.CenterLevel;
import com.zscat.mallplus.center.service.ICenterLevelService;
import com.zscat.mallplus.utils.CommonResult;

/**
 * 会员等级设置Controller
 * 
 * @author Wsen
 * @date 2020-09-24
 */
@RestController
@RequestMapping("/center/level")
public class CenterLevelController extends BaseController
{
    @Autowired
    private ICenterLevelService centerLevelService;

    /**
     * 查询会员等级设置列表
     */
//    @PreAuthorize("@ss.hasPermi('center:level:list')")
    @GetMapping("/list")
    public Object list(CenterLevel centerLevel)
    {
        List<CenterLevel> list = centerLevelService.selectCenterLevelList(centerLevel);
        return new CommonResult().success(list);
    }

    /**
     * 获取会员等级设置详细信息
     */
//    @PreAuthorize("@ss.hasPermi('center:level:query')")
    @GetMapping(value = "/{id}")
    public Object getInfo(@PathVariable("id") Long id)
    {
        return new CommonResult().success(centerLevelService.selectCenterLevelById(id));
    }

    /**
     * 新增会员等级设置
     */
//    @PreAuthorize("@ss.hasPermi('center:level:add')")
    @PostMapping
    public Object add(@RequestBody CenterLevel centerLevel)
    {
        return toAjax(centerLevelService.insertCenterLevel(centerLevel));
    }

    /**
     * 修改会员等级设置
     */
//    @PreAuthorize("@ss.hasPermi('center:level:edit')")
    @PutMapping
    public Object edit(@RequestBody CenterLevel centerLevel)
    {
        return toAjax(centerLevelService.updateCenterLevel(centerLevel));
    }

    /**
     * 删除会员等级设置
     */
//    @PreAuthorize("@ss.hasPermi('center:level:remove')")
	@DeleteMapping("/{ids}")
    public Object remove(@PathVariable Long[] ids)
    {
        return toAjax(centerLevelService.deleteCenterLevelByIds(ids));
    }
}
